<?php include('./templete/public/head.php')?>

<body class="bgcolor">

<div class="info-main">
    <div class="info-content">
        <input type="text" placeholder="旧密码" id="old_password">
        <input type="text" placeholder="新密码" id="password">
        <button type="button" class="layui-btn layui-btn-normal" style="margin-left: 35%" onclick="updatePassword()">确认提交</button>
    </div>
</div>
</body>
<script>
    function updatePassword() {
        var old_password = $("#old_password").val();
        var password = $("#password").val();
        if (!old_password){
            layer.msg('旧密码不能为空');
            return false;
        }
        if (!password){
            layer.msg('新密码不能为空');
            return false;
        }
        $.ajax({
            url:'<?php echo url('updatePassword')?>',
            data:{'password':password,'oldpassword':old_password},
            success:function (data) {
                if (data.code === 1) {
                   layer.msg(data.msg);
                   setTimeout(function () {
                       location.href = data.url;
                   }, 1000)
               }else{
                   layer.msg(data.msg);
               }
            }
        })
    }
</script>
</html>